clear; clc;
dataset = 'netfix';
load(strcat('../noncvx-lowrank/data/recsys/', dataset, '.mat'));

[row, col, val] = find(data);
idx = randperm(length(val));

traIdx = idx(1:floor(length(val)*0.5));
tstIdx = idx(ceil(length(val)*0.5): end);

clear idx;

traData = sparse(row(traIdx), col(traIdx), val(traIdx));
traData(size(data,1), size(data,2)) = 0;

para.maxIter = 5000;
para.decay = 0.8;

%% start testing
lambdaMax = sqrt(sum(val.^2));

lambda = (1.5*lambdaMax)/250;
para.tol = 1e-1;
para.maxR = 300;

t = tic;
[U, S, V, out{1}] = AccSoftImpute( traData', lambda, para );
Time(1) = toc(t);
RMSE(1) = MatCompRMSE(V, U, S, row(tstIdx), col(tstIdx), val(tstIdx));
clear U S V t;
  
% t = tic;
% [U, S, V, out{2}] = SoftImpute( traData', lambda, para );
% Time(2) = toc(t);
% RMSE(2) = MatCompRMSE(V, U, S, row(tstIdx), col(tstIdx), val(tstIdx));
% clear U S V t;

clear U S V tstIdx traIdx row col val idx data traData;
